package com.macaque.base.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.macaque.common.utils.HttpUtils;

public class GlobalInterceptor implements HandlerInterceptor {

	public void afterCompletion(HttpServletRequest arg0,
			HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
	}

	public void postHandle(HttpServletRequest request, HttpServletResponse response,
			Object handler, ModelAndView modelAndView) throws Exception {
		/*if (null == modelAndView) {
			return;
		}*/
		// 系统配置参数
		String basePath = HttpUtils.getBasePath(request);
		String contextPath = HttpUtils.getContextPath(request);
		/*modelAndView.addObject("basePath", basePath);
		modelAndView.addObject("contextPath", contextPath);*/
		request.setAttribute("basePath", basePath);
		request.setAttribute("contextPath", contextPath);
	}

	public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
			Object handler) throws Exception {
		System.out.println("---------------------");
		return true;
	}

}
